import { getUserInfoUrl } from "@/command/apiTool";
import { useDetail, useList } from "@/hooks";
import { getAction, postAction } from "@/command/netTool";
import { onMounted, reactive, ref, watch } from "vue";
export const useRequest = () => {
  let left = ref([]);
  let right = ref([
    {
      pid: "",
      id:'',
      path: "",
      title: "",
    },
  ]);
  onMounted(() => {
    getLeftMenu();
  });

  const getLeftMenu = () => {
    getAction(
      getUserInfoUrl({
        dh: "/api/H5/richCourse/large/queryCourseType",
        xh: "/api/H5/richCourse/large/queryCourseType",
      }).url
    ).then((e) => {
      left.value = e;
      getRight(e[0].id);
    });
  };
  const getRight = (id: string) => {
    getAction(
      getUserInfoUrl({
        dh: "/api/H5/richCourse/large/queryCourseData",
        xh: "/api/H5/richCourse/large/queryCourseData",
      }).url,
      {
        id: id,
      }
    ).then((e) => {
      right.value = e;
    });
  };

  return {
    left,
    right,
    getRight,
  };
};
